package com.dialatect;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Vitor
 */
import java.sql.Types;  
  
import org.hibernate.cfg.Environment;  
import org.hibernate.dialect.Dialect;  
  
public class AccessDialect extends Dialect {  
    public AccessDialect() {  
        super();  
        registerColumnType(Types.BIT, "BIT");  
        registerColumnType(Types.BIGINT, "INTEGER");  
        registerColumnType(Types.SMALLINT, "SMALLINT");  
        registerColumnType(Types.TINYINT, "BYTE");  
        registerColumnType(Types.INTEGER, "INTEGER");  
        registerColumnType(Types.CHAR, "VARCHAR(1)");  
        registerColumnType(Types.VARCHAR, "VARCHAR($l)");  
        registerColumnType(Types.FLOAT, "DOUBLE");  
        registerColumnType(Types.DOUBLE, "DOUBLE");  
        registerColumnType(Types.DATE, "DATETIME");  
        registerColumnType(Types.TIME, "DATETIME");  
        registerColumnType(Types.TIMESTAMP, "DATETIME");  
        registerColumnType(Types.VARBINARY, "VARBINARY($l)");  
        registerColumnType(Types.NUMERIC, "NUMERIC");  
        registerColumnType( Types.BIT, "boolean" );
        registerColumnType( Types.CHAR, "varchar($l)" );
        registerColumnType( Types.VARCHAR, "varchar($l)" );
        registerColumnType(Types.LONGVARCHAR, "longvarchar");
        registerColumnType(Types.NUMERIC, "numeric($p,$s)");
        registerColumnType(Types.BOOLEAN, "boolean");
        registerColumnType( Types.BIGINT, "integer");//numeric(19,0)" );  // MS Access DON'T SUPPORT BIGINT
        registerColumnType(Types.TINYINT, "tinyint"); //HXTT Access' tinyint is from 0 to 255
        registerColumnType(Types.SMALLINT, "smallint");
        registerColumnType(Types.INTEGER, "integer");
        registerColumnType(Types.REAL, "real");
        registerColumnType( Types.FLOAT, "float" ); // HXTT Access DON'T SUPPORT FLOAT ,it will be a double type
        registerColumnType(Types.DOUBLE, "double");
        registerColumnType( Types.BINARY, 255, "binary" );
        registerColumnType(Types.VARBINARY, 255, "varbinary");
        registerColumnType( Types.LONGVARBINARY, "longvarbinary");
        registerColumnType( Types.DATE, "date" );
        registerColumnType( Types.TIME, "timestamp");//time" );   //  HXTT Access DON'T SUPPORT TIME
        registerColumnType(Types.TIMESTAMP, "timestamp");
        registerColumnType( Types.BLOB, "blob" ); // BLOB COLUMN WILL CHANGE TO  JAVA_OBJECT TYPE COLUMN
        registerColumnType( Types.CLOB, "longvarchar" ); // CLOB COLUMN WILL CHANGE TO  LONGVARCHAR TYPE COLUMN
        registerColumnType(Types.OTHER, "currency");
        registerColumnType(Types.BLOB, "ole");
        registerColumnType( Types.JAVA_OBJECT, "java_object" );
        getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE,  
                "0");  
    }  
  
    public String getIdentityColumnString() {  
        return "AutoNumber NOT NULL";  
    }  
  
    public String getIdentitySelectString() {  
        return "select @@IDENTITY";  
    }  
    
    public boolean supportsCascadeDelete() {
        return true;//false;
    }
  
}  
